<form id="TaskForm" action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card" data-table-id="TaskTable">
    <div class="layui-card-body">
        <div class="layui-form-item">
            <label class="layui-form-label ">飞手昵称</label>
            <div class="layui-input-block">
                <div class="layui-input">{$vo.pilot.nickname|default=""}</div>
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label ">飞手姓名</label>
            <div class="layui-input-block">
                <div class="layui-input">{$vo.pilot.realname|default=""}</div>
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label ">飞手电话</label>
            <div class="layui-input-block">
                <div class="layui-input">{$vo.pilot.phone|default=""}</div>
                <p class="help-block"></p>
            </div>
        </div>

<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label ">发单人</label>-->
<!--            <div class="layui-input-block">-->
<!--                <div class="layui-input">{$vo.task.merchant.company|default=" - "}[{$vo.task.merchant.nickname|default=" - "}]</div>-->
<!--                <p class="help-block"></p>-->
<!--            </div>-->
<!--        </div>-->

        <!--        <div class="layui-form-item">-->
        <!--            <label class="layui-form-label ">订单任务分类</label>-->
        <!--            <div class="layui-input-block">-->
        <!--                <div class="layui-input">{$vo.task.category.name|default=""}</div>-->
        <!--                <p class="help-block"></p>-->
        <!--            </div>-->
        <!--        </div>-->

        <!--        <div class="layui-form-item ">-->
        <!--            <label class="layui-form-label">订单任务名称</label>-->
        <!--            <div class="layui-input-block disabled">-->
        <!--                <div class="layui-input">{$vo.task.name|default=""}</div>-->
        <!--                <p class="help-block"></p>-->
        <!--            </div>-->
        <!--        </div>-->



        <div class="layui-form-item transport-cate">
            <label class="layui-form-label ">货物种类</label>
            <div class="layui-input-block">
                {if $vo.task.transport.type == '其他'}
                <div class="layui-input">{$vo.task.transport.type|default="-"} [{$vo.task.transport.type_other|default="-"}]</div>
                {else}
                <div class="layui-input">{$vo.task.transport.type|default="-"}</div>
                {/if}
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item transport-cate">
            <label class="layui-form-label -next">运输场景</label>
            <div class="layui-input-block">
                {if $vo.task.transport.scene == '其他'}
                <div class="layui-input">{$vo.task.transport.scene|default="-"} [{$vo.task.transport.scene_other|default="-"}]</div>
                {else}
                <div class="layui-input">{$vo.task.transport.scene|default="-"}</div>
                {/if}
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item transport-cate">
            <label class="layui-form-label ">订单距离</label>
            <div class="layui-input-block">
                <div class="layui-input">{$vo.task.transport.distance|default=""}</div>
                <p class="help-block"></p>
            </div>
        </div>

        <div class="layui-form-item transport-cate">
            <label class="layui-form-label">货物重量</label>
            <div class="layui-input-block">
                <div class="layui-input">{$vo.task.transport.weight|default=""}</div>
                <p class="help-block">单位：吨</p>
            </div>
        </div>

        <div class="layui-form-item no-transport-cate">
            <label class="layui-form-label">任务时间</label>
            <div class="layui-input-block">
                <div class="layui-input">{$vo.task.exec_at|default=""}</div>
                <p class="help-block"></p>
            </div>
        </div>

        <!--        <div class="layui-form-item transport-cate">-->
        <!--            <label class="layui-form-label">开始时间</label>-->
        <!--            <div class="layui-input-block">-->
        <!--                <div class="layui-input">{$vo.task.transport.start_at|default=""}</div>-->
        <!--                <p class="help-block"></p>-->
        <!--            </div>-->
        <!--        </div>-->

        <!--        <div class="layui-form-item transport-cate">-->
        <!--            <label class="layui-form-label">结束时间</label>-->
        <!--            <div class="layui-input-block">-->
        <!--                <div class="layui-input">{$vo.task.transport.end_at|default=""}</div>-->
        <!--                <p class="help-block"></p>-->
        <!--            </div>-->
        <!--        </div>-->

        <div class="layui-form-item ">
            <label class="layui-form-label">任务地点</label>
            <div class="layui-input-block ">
                <div class="layui-input">{$vo.task.place|default=""}</div>
                <p class="help-block"></p>
            </div>
        </div>

        <!--        <div class="layui-form-item transport-cate">-->
        <!--            <label class="layui-form-label">起飞地点</label>-->
        <!--            <div class="layui-input-block ">-->
        <!--                <div class="layui-input">{$vo.task.transport.place|default=""}</div>-->
        <!--                <p class="help-block"></p>-->
        <!--            </div>-->
        <!--        </div>-->

        <!--        <div class="layui-form-item transport-cate">-->
        <!--            <label class="layui-form-label">到达地点</label>-->
        <!--            <div class="layui-input-block ">-->
        <!--                <div class="layui-input">{$vo.task.transport.place2|default=""}</div>-->
        <!--                <p class="help-block"></p>-->
        <!--            </div>-->
        <!--        </div>-->

        <div class="layui-form-item">
            <label class="layui-form-label">订单金额</label>
            <div class="layui-input-block">
                <div class="layui-input">{$vo.money|default=" - "}</div>
                <p class="help-block">单位：元</p>
            </div>
        </div>

        <!--        <div class="layui-form-item">-->
        <!--            <label class="layui-form-label">订单任务描述</label>-->
        <!--            <div class="layui-input-block">-->
        <!--                <textarea name="desc" placeholder="" class="layui-textarea">{$vo.task.desc|default=""}</textarea>-->
        <!--                <p class="help-block"></p>-->
        <!--            </div>-->
        <!--        </div>-->

        <div class="layui-form-item">
            <label class="layui-form-label">订单要求</label>
            <div class="layui-input-block">
                <textarea name="require" placeholder="" class="layui-textarea">{$vo.task.require|default=""}</textarea>
                <p class="help-block"></p>
            </div>
        </div>
    </div>

    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

    <!--    <div class="layui-form-item text-center">-->
    <!--        <button class="layui-btn" type='submit'>保存数据</button>-->
    <!--        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>-->
    <!--    </div>-->
</form>

<script>
    // 时间选择器
    laydate.render({elem: '#exectime', type: 'datetime'});
    layui.use('form', function(){
        var form = layui.form;
        // 选择表单元素
        var formElement = document.getElementById('TaskForm');
        var formElements = formElement.querySelectorAll('input, select, textarea, .layui-input');
        // 排除指定元素
        // formElements = Array.from(formElements).filter(el => !['id', 'task_status', 'review_reason'].includes(el.getAttribute('name')));
        // 遍历这些元素并禁用它们
        formElements.forEach(function(el) {
            el.disabled = true;
            el.classList.add('layui-disabled');
        });
        // 如果需要动态更新Layui样式，可以重新渲染表单
        form.render();

        // 显示隐藏默认值
        function toggleTransportCate(categoryId) {
            const isTransport = categoryId == 1;
            $(".transport-cate").toggle(isTransport);
            $(".no-transport-cate").toggle(!isTransport);
        }
        // 监听分类修改
        form.on('select(category_id)', function(data){
            toggleTransportCate(data.value);
        });
        // 初始化时执行一次
        toggleTransportCate({$vo.task.category_id});
    });
</script>